import 'package:enterprise_v6_app/app/components/special_operation/custom_high_input_page.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_multi_signature_page.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_picker_photo.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_select_function.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_select_page.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/data/entities/application/execute_entity.dart';

///特殊作业-审批节点
///[workCheck] 审批节点数据
///[onCallBack] 更新回调
///[isEnabled] 是否可编辑
class CustomApprovalNodePage extends StatefulWidget {
  const CustomApprovalNodePage({
    required this.workCheck,
    required this.onCallBack,
    super.key,
    this.isEnabled = true,
  });

  final ExecuteWorkCheckList workCheck;
  final Function() onCallBack;
  final bool isEnabled;

  @override
  State<CustomApprovalNodePage> createState() => _CustomApprovalNodePageState();
}

class _CustomApprovalNodePageState extends State<CustomApprovalNodePage> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.w),
      ),
      child: Column(
        children: [
          CustomMultiSignaturePage(
            title: widget.workCheck.checkProject ?? '',
            isEnabled: widget.isEnabled,
            signatureLists: widget.workCheck.checkUserSign ?? [],
            onCallBack: (value) {
              widget.workCheck.checkUserSign = value;
              widget.onCallBack();
            },
          ),
          CustomHighInputPage(
            isEnabled: widget.isEnabled,
            isShowTitle: false,
            text: widget.workCheck.checkReason,
            hintText: widget.workCheck.checkProject == '完工验收' ? '现场已清理，未留下隐患' : '同意',
            onCallBack: (value) {
              widget.workCheck.checkReason = value;
              widget.onCallBack();
            },
            isShowDivider: false,
          ),
          AppGaps.vGap20,
          Divider(
            height: 1.w,
            color: AppColors.bg_color_grey,
          ),
          CustomSelectPage(
              title: '日期选择',
              isEnabled: widget.isEnabled,
              selectText: widget.workCheck.checkDate ?? '',
              onCallBack: () {
                CustomSelectFunction.selectDateTime(onCallBack: (String value) {
                  widget.workCheck.checkDate = value;
                  widget.onCallBack();
                });
              }),
          CustomPickerPhoto(
            title: '拍照认证：',
            imagesList: widget.workCheck.checkImage!,
            titleTextStyle: TextStyle(
              color: const Color(0xFF262F38),
              fontSize: 14.sp,
              fontWeight: FontWeight.w400,
            ),
            isEnabled: widget.isEnabled,
            isRequired: true,
            // isEnabled: false,
            callback: (List<String> images) {
              widget.workCheck.checkImage = images;
              widget.onCallBack();
            },
          ),
        ],
      ),
    );
  }
}
